package principal;

import Composite.RacinePicasial;
import Composite.RacineLogique;
import Composite.RacineDossier;
import espace_physique.*;
import fichiers.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.JFrame;

public class ControleurFermerApplication extends WindowAdapter implements ActionListener{
    
    
    private Fenetre fenetre;
    
    public ControleurFermerApplication(Fenetre fenetre) {
    
        this.fenetre=fenetre;

    }

    public void actionPerformed(ActionEvent e) {
        
        this.fermer();
    }
    
    public void windowClosing(WindowEvent e) {
        
        this.fermer();
        
    }

    
    public void fermer(){
        
        this.fenetre.setVisible(false);
        ObjectOutputStream fos=null;
         try {
                fos = new ObjectOutputStream(new FileOutputStream("RacineLogique.data"));
                fos.writeObject(RacineLogique.getRacine());
 
                fos = new ObjectOutputStream(new FileOutputStream("RacineDossier.data"));
                fos.writeObject(RacineDossier.getRacine());
 
                fos = new ObjectOutputStream(new FileOutputStream("RacinePicasial.data"));
                fos.writeObject(RacinePicasial.getRacine());
            } catch (Exception ex) {
                ex.printStackTrace();
            }
          System.exit(0);  
        
    }
}
